
# -*- coding: utf-8 -*-

from PyQt5.QtGui import QImage
from PyQt5.QtCore import QByteArray, QBuffer, QIODevice

image_file = "/home/xxxx/Pictures/2020-03-07_13-40.png"
image = QImage(image_file)
print image
print image.save("/home/xxxx/Pictures/direct.jpg", "jpeg", quality=100)


# print image, image.size()
ba = QByteArray()
buffer = QBuffer(ba)
buffer.open(QIODevice.WriteOnly)
# 内存中转换
image.save(buffer, "jpeg", quality=100)
# res = image.save(buffer, "png")
buffer.close()

o_image = QImage.fromData(ba)
print o_image.fromData(ba, "jpeg")
print o_image.size().isEmpty()
print o_image.save("/home/xxxx/Pictures/buffer.jpg", "jpeg", quality=100)
